package com.school.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.school.pojo.Tpos;
import com.school.service.TposService;
import com.school.util.Result;
import com.school.util.Tool;

@RequestMapping("/tpos")
@RestController
public class TposController implements Tool<Tpos>{
	
	@Autowired
	private TposService tposService;
	
	@Override
	@RequestMapping("/findAll")
	public Result<Tpos> findAll(@RequestParam(defaultValue = "1",name="page")int page,@RequestParam(defaultValue = "10",name="limit")int pageSize, Tpos t) {
		List<Tpos> list= tposService.findAll(t,page,pageSize);
		PageInfo<Tpos> info=new PageInfo<>(list);
		Result<Tpos> result=new Result<Tpos>();
		result.setList(info.getList());
		result.setCount(info.getTotal());
		return result;
	}

	@Override
	@RequestMapping("/findbyId")
	public Result<Tpos> findbyId(int tpos_id) {
		Tpos tpos=tposService.findbyId(tpos_id);
		Result<Tpos> result=new Result<Tpos>();
		result.setData(tpos);
		return result;
	}

	@Override
	@RequestMapping("/add")
	public int add(Tpos t) {
		int row=tposService.add(t);
		return row;
	}

	@Override
	@RequestMapping("/edit")
	public int edit(Tpos t) {
		int row=tposService.edit(t);
		return row;
	}

	@Override
	public int del(int id) {
		
		return 0;
	}

	@Override
	@RequestMapping("/delbatch")
	public int delbatch(int[] id) {
		
		return tposService.delbatch(id);
	}

	
}
